import os
import time
from aip import AipOcr

AppID = '25175028'
API_Key = 'MnHYhrGYy0Rh5h7pSALvFFRS'
Secret_Key = 'iLwBnOuRe5qUeILjoK6UT9M8v9Auoday'

aipOcr = AipOcr(AppID, API_Key, Secret_Key)  # 初始化

Path = "E:/pythonV1/python-script/worm/img/"  # 图片路径
all_picture_Path = os.listdir(Path)  # 统计文件下图片个数


def get_content(picturePath):
    with open(picturePath, 'rb') as fp:
        return fp.read()


for picture in all_picture_Path:
    pic = get_content(Path + picture)
    res = aipOcr.numbers(pic, options=None)
    time.sleep(1)
    for i in range(0, len(res['words_result'])):
        print(picture, " ", res['words_result'][i]['words'])
